home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 8834 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.9 KB

  1. Path: news1.h1.usa.pipeline.com!usenet
  2. From: grantp@usa.pipeline.com(Pete)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: How can I include IOSTREAM.H only once?
  5. Date: 26 Feb 1996 22:29:29 GMT
  6. Organization: Kalevi, Inc.
  7. Message-ID: <4gtc89$b88@news1.usa.pipeline.com>
  8. NNTP-Posting-Host: pipe10.h1.usa.pipeline.com
  9. X-PipeUser: grantp
  10. X-PipeHub: usa.pipeline.com
  11. X-PipeGCOS: (Pete)
  12. X-Newsreader: Pipeline USA v3.3.0
  13.  
  14. On Feb 26, 1996 04:51:44 in article <How can I include IOSTREAM.H only
  15. once?>, 'bluefox@info.polymtl.ca (Michael Gaudette)' wrote: 
  16.  
  17.  
  18. >I am presently engaged in what is usually called "the learning process",  
  19. >and I've been programming simple programs with classes.  Because of this, 
  20.  
  21. >I have had to #include <iostream.h> in most of my "class.cpp" files AND  
  22. >in my main program. This (added to conio.h and all the other standard  
  23. >libraries) usually result in a simple program being 20000 lines long. 
  24. >Is there any way (using Borland v4.5) to make the compiler only link  
  25. >those files ONCE? 
  26. Yes and no.   
  27.  
  28. First the no.  The compiler must be able to "see" all the prototypes 
  29. in the header files, therefore, the files must be included in each 
  30. source file that uses funtions in those headers.  Of course, 
  31. if you only need one or two prototypes from each file, you 
  32. could just copy those into our own header, but that's really 
  33. not recommended. 
  34.  
  35. Now, the yes.  Precompiling headers goes a long way to ease 
  36. the pain.  To take maximum advantage of header file pre- 
  37. compiling, you need the include the standard set in the same 
  38. sequence in every file.  One way is to create a file incl.h 
  39. into which you place all the standard library header your 
  40. project uses, then include that file as the first file in all 
  41. of your source files.  Then, use a pragma hdrstop to further 
  42. enhance precompilation.  Read details in online docs 
  43. under the topic "precompiled headers". 
  44.  
  45. -- 
  46. Pete Grant 
  47. Kalevi, Inc. 
  48. Software Engineering & development
  49.